<?php

require_once(sfConfig::get('sf_lib_dir').'/filter/base/BaseFormFilterPropel.class.php');

/**
 * Commerces filter form base class.
 *
 * @package    virtualdelivery
 * @subpackage filter
 * @author     Your name here
 */
class BaseCommercesFormFilter extends BaseFormFilterPropel
{
  public function setup()
  {
    $this->setWidgets(array(
      'com_corporate_name'  => new sfWidgetFormFilterInput(),
      'com_trade_name'      => new sfWidgetFormFilterInput(),
      'com_cuit'            => new sfWidgetFormFilterInput(),
      'com_sta_id'          => new sfWidgetFormPropelChoice(array('model' => 'GeoStates', 'add_empty' => true)),
      'com_cty_id'          => new sfWidgetFormPropelChoice(array('model' => 'GeoCities', 'add_empty' => true)),
      'com_phone'           => new sfWidgetFormFilterInput(),
      'com_alternate_phone' => new sfWidgetFormFilterInput(),
      'com_fax'             => new sfWidgetFormFilterInput(),
      'com_web_site'        => new sfWidgetFormFilterInput(),
      'com_email'           => new sfWidgetFormFilterInput(),
      'com_picture'         => new sfWidgetFormFilterInput(),
      'com_coverage_area'   => new sfWidgetFormFilterInput(),
    ));

    $this->setValidators(array(
      'com_corporate_name'  => new sfValidatorPass(array('required' => false)),
      'com_trade_name'      => new sfValidatorPass(array('required' => false)),
      'com_cuit'            => new sfValidatorPass(array('required' => false)),
      'com_sta_id'          => new sfValidatorPropelChoice(array('required' => false, 'model' => 'GeoStates', 'column' => 'sta_id')),
      'com_cty_id'          => new sfValidatorPropelChoice(array('required' => false, 'model' => 'GeoCities', 'column' => 'cty_id')),
      'com_phone'           => new sfValidatorPass(array('required' => false)),
      'com_alternate_phone' => new sfValidatorPass(array('required' => false)),
      'com_fax'             => new sfValidatorPass(array('required' => false)),
      'com_web_site'        => new sfValidatorPass(array('required' => false)),
      'com_email'           => new sfValidatorPass(array('required' => false)),
      'com_picture'         => new sfValidatorPass(array('required' => false)),
      'com_coverage_area'   => new sfValidatorPass(array('required' => false)),
    ));

    $this->widgetSchema->setNameFormat('commerces_filters[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    parent::setup();
  }

  public function getModelName()
  {
    return 'Commerces';
  }

  public function getFields()
  {
    return array(
      'com_id'              => 'Number',
      'com_corporate_name'  => 'Text',
      'com_trade_name'      => 'Text',
      'com_cuit'            => 'Text',
      'com_sta_id'          => 'ForeignKey',
      'com_cty_id'          => 'ForeignKey',
      'com_phone'           => 'Text',
      'com_alternate_phone' => 'Text',
      'com_fax'             => 'Text',
      'com_web_site'        => 'Text',
      'com_email'           => 'Text',
      'com_picture'         => 'Text',
      'com_coverage_area'   => 'Text',
    );
  }
}
